<template>
  <div class="dormitory-process">
    <div class="header">
      <div class="header-content">
        <router-link class="back-btn" to="/main/process">
          <i class="el-icon-arrow-left"></i>
          <span>返回</span>
        </router-link>
        <h2 class="page-title">宿舍管理流程</h2>
      </div>
    </div>

    <div class="process-timeline">
      <el-steps :active="currentStep" finish-status="success" align-center>
        <el-step title="宿舍申请" @click.native="goToStep('apply')">
          <template slot="icon">
            <i class="el-icon-document"></i>
          </template>
        </el-step>
        <el-step title="审批分配" @click.native="goToStep('approval')">
          <template slot="icon">
            <i class="el-icon-s-check"></i>
          </template>
        </el-step>
        <el-step title="入住登记" @click.native="goToStep('checkin')">
          <template slot="icon">
            <i class="el-icon-s-home"></i>
          </template>
        </el-step>
        <el-step title="日常管理" @click.native="goToStep('manage')">
          <template slot="icon">
            <i class="el-icon-s-tools"></i>
          </template>
        </el-step>
        <el-step title="退宿办理" @click.native="goToStep('checkout')">
          <template slot="icon">
            <i class="el-icon-circle-close"></i>
          </template>
        </el-step>
      </el-steps>

      <div class="process-content">
        <div class="current-step-info">
          <h3>{{ getCurrentStepTitle() }}</h3>
          <p>{{ getCurrentStepDescription() }}</p>
          <el-button type="primary" @click="handleCurrentStep">进入当前步骤</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      currentStep: 0,
      steps: [
        { title: '宿舍申请', path: '/main/wuye/dormitory/apply', description: '填写宿舍申请信息' },
        { title: '审批分配', path: '/main/wuye/dormitory/approval', description: '审批并分配宿舍' },
        { title: '入住登记', path: '/main/wuye/dormitory/checkin', description: '办理入住手续' },
        { title: '日常管理', path: '/main/wuye/dormitory/manage', description: '宿舍日常管理' },
        { title: '退宿办理', path: '/main/wuye/dormitory/checkout', description: '办理退宿手续' }
      ]
    }
  },
  methods: {
    getCurrentStepTitle() {
      return this.steps[this.currentStep].title
    },
    getCurrentStepDescription() {
      return this.steps[this.currentStep].description
    },
    handleCurrentStep() {
      const currentStepPath = this.steps[this.currentStep].path
      if (currentStepPath) {
        this.$router.push(currentStepPath)
      } else {
        this.$message.info('该步骤功能开发中')
      }
    },
    goToStep(path) {
      this.$router.push(`/main/wuye/dormitory/${path}`)
    }
  }
}
</script>

<style lang="scss" scoped>
.dormitory-process {
  padding: 20px;

  .header {
    margin-bottom: 30px;
    position: relative;
    
    .header-content {
      text-align: center;
    }

    .back-btn {
      position: absolute;
      left: 0;
      top: 50%;
      transform: translateY(-50%);
      text-decoration: none;
      color: #606266;
      display: flex;
      align-items: center;
    }

    .page-title {
      margin: 0;
      font-size: 24px;
      color: #303133;
    }
  }

  .process-timeline {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1);

    .el-steps {
      margin-bottom: 40px;
    }
  }

  .process-content {
    padding: 20px;
    border-top: 1px solid #EBEEF5;

    .current-step-info {
      text-align: center;

      h3 {
        color: #303133;
        margin-bottom: 10px;
      }

      p {
        color: #606266;
        margin-bottom: 20px;
      }
    }
  }

  :deep(.el-step__icon) {
    cursor: pointer;
  }
}
</style> 